#pragma once
#include <i_component.h>
#include <modules/i_command.h>
#include <mutex>
#include <thread>
#include <list>

class CCommand : public ICommand, public CComponent
{
public:
	CCommand();
	virtual ~CCommand();

	signal<const CCommandInfoPtr&>& GetCommandSignal(const std::string& cmd) override;

	void PostCommand(const CCommandInfoPtr& cmd) override;

protected:
	virtual int _OnStart() override;
	virtual void _OnStop() override;

	CCommandInfoPtr _Parse(std::string& input);
	void _Svc();
protected:
	std::thread m_worker;
	std::unordered_map<std::string, signal<const CCommandInfoPtr&>> m_signals;
};